package com.wanmait.myhouse.mediatorController;

import com.wanmait.myhouse.dao.ContactDAO;
import com.wanmait.myhouse.dao.MediatorDAO;
import com.wanmait.myhouse.dao.UserDAO;
import com.wanmait.myhouse.vo.Contact;
import com.wanmait.myhouse.vo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("mediator")
public class MediatorHandleController {
    @GetMapping("handle")
    public String handle(Contact contact, Model model) {
        ContactDAO contactDAO = new ContactDAO();
        Contact contact1 = contactDAO.FindBy(contact);
        UserDAO userDAO = new UserDAO();
        User user = userDAO.findById(contact.getUserId());
        contact1.setUser(user);


        model.addAttribute("contact",contact1);
        return "mediator/handle";
    }
}
